package com.lx.service;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import com.lx.entities.User;

@Service
public class UserService {

	@Autowired
	private RedisTemplate<String, User> redis;

	public void saveUser() {
		List<User> uList = new ArrayList<>();
		uList.add(new User(1, "张三", 24));
		uList.add(new User(2, "李四", 80));
		uList.add(new User(3, "王五", 90));
		redis.opsForList().leftPushAll("users", uList);
	}

	public void showUser() {
		List<User> range = redis.opsForList().range("users", 0, -1);
		System.out.println(range);
	}
}
